package common.db.repository;

import java.util.Map;
import java.util.HashMap;

/**
 * Created by IntelliJ IDEA.
 * User: ppopovic
 * Date: 18.10.2009.
 * Time: 11.40.56
 * To change this template use File | Settings | File Templates.
 */
public class PackageRepository
{
	private static Map<String, Resourcer> instances = new HashMap<String, Resourcer>();
	private static Map<String, SqlQueryGenerator> sqlQueryGenInstances = new HashMap<String, SqlQueryGenerator>();

	public synchronized static Resourcer getInstance(String pckg)
	{
		if (!instances.containsKey(pckg))
			instances.put(pckg, new Resourcer(pckg));

		return instances.get(pckg);
	}

	public synchronized static SqlQueryGenerator getSqlQueryGenInstance(String pckg)
	{
		if (!sqlQueryGenInstances.containsKey(pckg))
		{
			Resourcer resourcer = getInstance(pckg);
			sqlQueryGenInstances.put(pckg, new SqlQueryGenerator(resourcer));
		}

		return sqlQueryGenInstances.get(pckg);
	}
}
